package HomeWork.filePracrice;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class a05 {
    public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
        System.out.println("Please enter a file name:");
        String input=sc.next();
        File file=new File("./"+input);
        //持续对是否存在进行判断
        while(true) {
            if(file.exists()){
                System.out.println("已经存在,请重新输入：");
                input=sc.next();
                file=new File("./"+input);
            }else{
                System.out.println("恭喜，文件不存在，接下来为您创建！");
                file.createNewFile();
                break;
            }
        }
    }
}
